package avicit.bdp.dds.api.service;

import avicit.bdp.common.base.BaseService;
import avicit.bdp.common.utils.EntityUtils;
import avicit.bdp.dds.dao.entity.LineageFieldDTO;
import avicit.bdp.dds.dao.entity.ProcessDefinition;
import avicit.bdp.dds.dao.mapper.LineageFieldDAO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/** 
 * 数据血缘字段关系服务
 *
 */
@Service
@Transactional
public class LineageFieldService extends BaseService<LineageFieldDAO, LineageFieldDTO> {

    @Autowired
    private LineageFieldDAO lineageFieldDAO;

    public int batchInsert(List<LineageFieldDTO> lineageFieldList) {
        if (CollectionUtils.isNotEmpty(lineageFieldList)) {
            for (LineageFieldDTO obj : lineageFieldList) {
                EntityUtils.setCreateAndUpdateInfo(obj);
            }
            return lineageFieldDAO.batchInsert(lineageFieldList);
        }
        return 0;
    }

    public List<LineageFieldDTO> selectAllLineageFieldByTableIds(List<String> tableIdList) {
        return lineageFieldDAO.selectAllLineageFieldByTableIds(tableIdList);
    }

    public List<ProcessDefinition> getProcessDefinitionList(List<String> idList) {
        return lineageFieldDAO.getProcessDefinitionList(idList);
    }

}
